home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0429.dms / q0429.adf / libray / libcommon / translate.c < prev    next >
C/C++ Source or Header  |  1991-08-08  |  2KB  |  75 lines

  1. /*
  2.  * translate.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  * 
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * $Id: translate.c,v 4.0 91/07/17 14:32:42 kolb Exp Locker: kolb $
  17.  *
  18.  * $Log:    translate.c,v $
  19.  * Revision 4.0  91/07/17  14:32:42  kolb
  20.  * Initial version.
  21.  * 
  22.  */
  23. #include "common.h"
  24. #include "translate.h"
  25.  
  26. TransMethods *iTranslateMethods;
  27. void TranslationMatrix();
  28.  
  29. Translate *
  30. TranslateCreate()
  31. {
  32.     Translate *res;
  33.  
  34.     res = (Translate *)Malloc(sizeof(Translate));
  35.     res->x = res->y = res->z = 0.;
  36.     return res;
  37. }
  38.  
  39. TransMethods *
  40. TranslateMethods()
  41. {
  42.     if (iTranslateMethods == (TransMethods *)NULL) {
  43.         iTranslateMethods = (TransMethods *)Malloc(sizeof(TransMethods));
  44.         iTranslateMethods->create = (TransCreateFunc *)TranslateCreate;
  45.         iTranslateMethods->propagate = TranslatePropagate;
  46.     }
  47.     return iTranslateMethods;    
  48. }
  49.  
  50. void
  51. TranslatePropagate(translate, trans, itrans)
  52. Translate *translate;
  53. RSMatrix *trans, *itrans;
  54. {
  55.     TranslationMatrix(translate->x, translate->y, translate->z, trans);
  56.     /*
  57.      * Build the inverse...
  58.      */
  59.     MatrixInit(itrans);
  60.     itrans->translate.x = -translate->x;
  61.     itrans->translate.y = -translate->y;
  62.     itrans->translate.z = -translate->z;
  63. }
  64.  
  65. void
  66. TranslationMatrix(x, y, z, mat)
  67. Float x, y, z;
  68. RSMatrix *mat;
  69. {
  70.     MatrixInit(mat);
  71.     mat->translate.x = x;
  72.     mat->translate.y = y;
  73.     mat->translate.z = z;
  74. }
  75.